import "ol/ol.css";
import Map from "ol/Map";
import View from "ol/View";
import TileLayer from "ol/layer/Tile";
import XYZ from "ol/source/XYZ";

export function initMap () {
  const olMap = new Map({
    target: "map",
    layers: [
      new TileLayer({
        source: new XYZ({
          crossOrigin: 'Anonymous', // 是否请求跨域操作
          url: "https://{a-c}.tile.openstreetmap.org/{z}/{x}/{y}.png",
        }),
      }),
    ],
    view: new View({
      center: [0, 0],
      zoom: 9.027,
      // projection: 'EPSG:4326',
    }),
  });

  return olMap;
}
